<template>
  <!-- 收藏的专辑 -->
  <div class="mtop-20">
    <el-card>
      <div class="submv-head">
        <div>
          <span class="font-bold">收藏的视频</span>
          <span class="fon-12" style="color: #cfcfcf">({{ count }})</span>
        </div>
        <div class="detail-search">
          <el-input
            placeholder="搜索收藏视频"
            clearable
            suffix-icon="el-icon-search"
            v-model="key"
          ></el-input>
        </div>
      </div>
      <div class="mtop-20 video-list">
        <ul>
          <li v-for="(v, index) in videoList" :key="index">
            <div class="mtop-20 img-wrap">
              <img
                :src="v.coverUrl + '?param=300y170'"
                class="video-img pointer"
                @click="toDetail(v)"
              />
              <div class="video-playcount font-12">
                <i class="iconfont icon-24gl-play"></i>
                {{ v.playTime | countFormat }}
              </div>
              <div class="video-time font-12">
                {{ (v.durationms / 1000) | timeFormat }}
              </div>
              <div class="play-btn pointer" @click="toDetail(v)">
                <i class="iconfont icon-bofang"></i>
              </div>
            </div>

            <div class="title-line text-hidden font-14">{{ v.title }}</div>
            <div class="author-line font-12">
              {{ v.creator[0].name }}
            </div>
          </li>
        </ul>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getSubMv } from "@/api/request";
export default {
  data() {
    return {
      list: [],
      key: "",
      count: 0,
      offset: 0,
    };
  },
  computed: {
    videoList() {
      return this.list.filter((item) => item.title.match(this.key));
    },
  },
  created() {
    this.getMvList();
  },
  methods: {
    async getMvList() {
      const { data: res } = await getSubMv();
      console.log(res);
      if (res.code !== 200) return;
      this.list = res.data;
      this.count = res.count;
    },
    toDetail(v){
      console.log(v);
      if(v.type === 0){
        this.$router.push('/videodetail/mv/' + v.vid);
      } else {
        this.$router.push('/videodetail/v/' + v.vid);
      }
    },
  },
};
</script>

<style lang="less" scoped>

.submv-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.video-list {
  ul {
    display: flex;
    flex-wrap: wrap;
    li {
      width: 22%;
      margin-right: 3%;
      .title-line {
        margin: 4px 0;
      }
      .author-line {
        margin: 2px 0;
        color: #cfcfcf;
      }
    }
  }
}
.img-wrap {
  position: relative;
  .video-img {
    width: 100%;
    border-radius: 5px;
  }
  .video-playcount {
    color: #ffffff;
    position: absolute;
    right: 10px;
    top: 10px;
    .iconfont {
      font-size: 12px;
    }
  }
  .video-time {
    color: #ffffff;
    position: absolute;
    right: 10px;
    bottom: 10px;
  }
  .play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fbf6f7;
    color: #ec4141;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.5s;
    i {
      font-size: 18px;
    }
  }
  &:hover .play-btn {
    opacity: 1;
  }
}
</style>